<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>欢迎</title>
    <script type="text/javascript" src="/erp/js/jquery.2.1.4.js"></script>

    <style>
        #show {
            background: url("image/login.jpg") no-repeat;
            height: 50%;
            width: 30%;
            overflow: hidden;
            background-size: 100%;
            margin: 60px auto;
        }
    </style>
</head>
<body>
<div id="show">
    <div style="margin:70px 0px 0px 90px">
        <form method="post">
            <br> <font color="white"> 用户名：</font><input id="username" type="text" name="username">
            <span id="tag1" style="color: red"></span> <br><br>
           <font color="white"> 密&nbsp;&nbsp;&nbsp;码：</font><input id="password" type="password" name="pwd">
            <span id="tag2" style="color: red"></span><br><br>
            <input type="button" value="登录" onclick="login();"/>&nbsp;&nbsp;&nbsp;
            <span id="tag3" style="color: red">${dis}</span>
        </form>
    </div>
</div>

</body>
<script>
    function login() {
        var flag = true;
        $("#tag1").html("");
        $("#tag2").html("");
        $("#tag3").html("");
        if ($("#username").val().trim() == "") {
            $("#tag1").html("用户名不能为空");
            flag = false;
        }
        if ($("#password").val().trim() == "") {
            $("#tag2").html("密码不能为空");
            flag = false;
        }
        if (flag) {
            var username = $("#username").val();
            var password = $("#password").val();

            $.post("/erp/userCtrl?parm=login", {username: username, password: password}, function (data) {
                    if (data == 1) {
                        $("#tag3").html("此用户已被禁用");
                    } else if (data == 2) {
                        $("#tag3").html("此用户已被删除");
                    } else if (data == 3) {
                        window.location.href = "page/main.jsp";
                    } else if (data == 4) {
                        $("#tag3").html("用户名或密码错误");
                    }
                }
            );
        }

    }
</script>
</html>
